package test;

import static org.junit.Assert.*;

import java.util.List;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.orm.hibernate4.HibernateTemplate;


import dao.DeptDao;
import entity.Dept;

public class testutil {


//	@Test
//	public void testName() throws Exception {
//		String configLocation="applicationContext.xml";
//		ApplicationContext ac=new ClassPathXmlApplicationContext(configLocation);
//		HibernateTemplate template=ac.getBean("template", HibernateTemplate.class);
//		Dept dept=template.get(Dept.class, 1);
//		System.out.print(dept.getNo()+" "+dept.getName());
//	}
//	
	@Test
	public void testfindAll() throws Exception {
		
		String configLocation="applicationContext.xml";
		ApplicationContext ac=new ClassPathXmlApplicationContext(configLocation);
		DeptDao deptDao=ac.getBean("deptDao", DeptDao.class);
		List<Dept> list=deptDao.findAll();
		for(Dept dept:list){
			System.out.print(dept.getNo()+" "+dept.getName());
		}
		
	}

	@Test
	public void testdelno() throws Exception {
	
		String configLocation="applicationContext.xml";
		ApplicationContext ac=new ClassPathXmlApplicationContext(configLocation);
		DeptDao deptDao=ac.getBean("deptDao", DeptDao.class);
		Dept dept=new Dept();
		
		deptDao.delete(4);

	    	  
	      }
		
	
		
		
	}
